package com.hrcx.mystery.dto.admin;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.hrcx.mystery.pojo.EbMysteryMerchandiseAssociated;
import com.hrcx.mystery.utils.quartz.cron.CronScheduleModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * <h1>新增盲盒对象请求封装</h1>
 *
 * @author LinXiPeng
 * @className NewMysteryDto
 * @date 2021/12/15 9:23
 * Version 1.0
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "新增盲盒对象请求封装")
public class NewMysteryDto implements Serializable {

    private static final long serialVersionUID = -8009733861408813619L;

    @ApiModelProperty("盲盒编号")
    private Integer id;

    /**
     * 盲盒名称
     */
    @NotBlank(message = "[盲盒名称]不能为空")
    @Size(max = 255, message = "盲盒名称长度不能超过255")
    @ApiModelProperty("盲盒名称")
    @Length(max = 255, message = "盲盒名称长度不能超过255")
    private String name;

    /**
     * 盲盒内商品的个数
     */
    @ApiModelProperty("盲盒内商品的个数")
    private Integer productcount;

    /**
     * 开盒单价
     */
    @NotNull(message = "[开盒单价]不能为空")
    @ApiModelProperty("开盒单价")
    private BigDecimal price;

    /**
     * 开盒次数
     */
    @ApiModelProperty("开盒次数")
    private Integer opennum;

    /**
     * 分区
     */
    @ApiModelProperty("分区")
    private Integer scope;

    /**
     * 商家ID
     */
    @NotNull(message = "[商家ID]不能为空")
    @ApiModelProperty("商家ID")
    private Integer creatby;

    /**
     * 开启时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss", iso = DateTimeFormat.ISO.DATE_TIME)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @NotNull(message = "[开启时间]不能为空")
    @ApiModelProperty("开启时间")
    @Future(message = "开启时间必须为未来的某个时间！")
    private Date starttime;

    /**
     * 结束时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss", iso = DateTimeFormat.ISO.DATE_TIME)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @NotNull(message = "[结束时间]不能为空")
    @ApiModelProperty("结束时间")
    @Future(message = "结束时间必须是未来的某个时间！")
    private Date endtime;

    /**
     * 奖池（利润池）
     */
    @ApiModelProperty("奖池（利润池）")
    @DecimalMin(value = "0", message = "奖池的金额必须>=0")
    private BigDecimal pond;

    /**
     * 成本池
     */
    @ApiModelProperty("成本池")
    @DecimalMin(value = "0", message = "成本池的金额必须>=0")
    private BigDecimal costPond;

    /**
     * 投注池
     */
    @ApiModelProperty("投注池")
    @DecimalMin(value = "0", message = "投注池的金额必须>=0")
    private BigDecimal bettingPond;

    /**
     * 利润比
     */
    @NotNull(message = "[利润比]不能为空")
    @ApiModelProperty("利润比")
    private Double profitShare;

    /**
     * 上限阈值
     */
    @ApiModelProperty("上限阈值")
    @DecimalMin(value = "0", message = "上限阈值必须>=0")
    private BigDecimal upperThreshold;

    /**
     * false：未开启 true：已开启
     */
    @NotNull(message = "[false：未开启 true：已开启 ]不能为空")
    @ApiModelProperty("false：未开启 true：已开启 ")
    private Boolean status;

    @ApiModelProperty("cron表达式生成对象")
    private CronScheduleModel cronScheduleModel;

    @ApiModelProperty("奖品集合")
    private List<EbMysteryMerchandiseAssociated> associatedList;

    @Override
    public String toString() {
        return "新创建的盲盒对象{" +
                "盲盒编号=" + id +
                ", 盲盒名称='" + name + '\'' +
                ", 奖品数量=" + productcount +
                ", 价格=" + price +
                ", 开盒次数=" + opennum +
                ", 分区=" + scope +
                ", 创建商户=" + creatby +
                ", 开启时间=" + starttime +
                ", 结束时间=" + endtime +
                ", 利润池金额=" + pond +
                ", 成本池金额=" + costPond +
                ", 投注池金额=" + bettingPond +
                ", 利润比=" + profitShare +
                ", 上限阈值=" + upperThreshold +
                ", 状态=" + status +
                '}';
    }
}